package com.example.demo.MyBlockingQueue;

public class MainTest {
    public static void main(String[] args) throws InterruptedException {
        MyBlockingQueue3<String> queue = new MyBlockingQueue3<String>(3);
        Thread t1 = new Thread(() -> {
            System.out.println(System.currentTimeMillis() + "begin");
            try {
                queue.offer("任务1");
                System.out.println(queue);
                queue.offer("任务2");
                System.out.println(queue);
                queue.offer("任务3");
                System.out.println(queue);
                queue.offer("任务4",1500);
                System.out.println(queue);
            } catch (InterruptedException e) {
                throw new RuntimeException("");
            }
            System.out.println(System.currentTimeMillis() + "end");
        });
        t1.start();
        Thread.sleep(1000);
        queue.poll();
    }
}